########### Figure 1#################
x_labels <- desc_tab[which(desc_tab$variable=="ability_support_bi"),c("Subgroup","Subgroup_n")]
plot_desc_points_a <- ggplot(subset(desc_tab,variable=="ability_support_bi"),aes(x=Subgroup,y=mean)) + 
  geom_errorbar(aes(ymin=ci.95.lo, ymax=ci.95.hi),
                position=position_dodge(width=0.5),
                width=0.25, size=0.5) +
  geom_point(aes(shape=Policy), 
             position=position_dodge(width=0.5),size=1.5) + 
  scale_y_continuous("% Support Policy",limits=c(0.2,0.83),
                     breaks=seq(0,1,0.2),
                     labels=100*seq(0,1,0.2)) + 
  scale_x_discrete("Subgroup",breaks=x_labels$Subgroup,labels=x_labels$Subgroup_n) + 
  facet_wrap("Policy",ncol = 1) + 
  # geom_text(data=desc_tab,aes(x = Subgroup,y=0.20,label=n)) +
  theme_bw() + 
  theme(legend.position = "none",
        strip.text = element_text(size=18),
        axis.text = element_text(size=12))
plot(plot_desc_points_a)
#### Panel B ########

plot_desc_points_b <- ggplot(subset(desc_tab,variable=="needs_support_bi"),aes(x=Subgroup,y=mean)) + 
  geom_errorbar(aes(ymin=ci.95.lo, ymax=ci.95.hi),
                position=position_dodge(width=0.5),
                width=0.25, size=0.5) +
  geom_point(aes(shape=Policy), 
             position=position_dodge(width=0.5),size=1.5) + 
  scale_y_continuous("% Support Policy",limits=c(0.2,0.83),
                     breaks=seq(0,1,0.2),
                     labels=100*seq(0,1,0.2)) + 
  scale_x_discrete("Subgroup",breaks=x_labels$Subgroup,labels=x_labels$Subgroup_n) + 
  facet_wrap("Policy",ncol = 1) + 
  # geom_text(data=desc_tab,aes(x = Subgroup,y=0.20,label=n)) +
  theme_bw() + 
  theme(legend.position = "none",
        strip.text=element_text(size=18),
        axis.text = element_text(size=12))
plot(plot_desc_points_b)

#### Panel C ########
x_labels <- desc_tab[which(desc_tab$variable=="dist_support_bi"),c("Subgroup","Subgroup_n")]
plot_desc_points_c <- ggplot(subset(desc_tab,variable=="dist_support_bi"),aes(x=Subgroup,y=mean)) + 
  geom_errorbar(aes(ymin=ci.95.lo, ymax=ci.95.hi),
                position=position_dodge(width=0.5),
                width=0.25, size=0.5) +
  geom_point(aes(shape=Policy), 
             position=position_dodge(width=0.5),size=1.5) + 
  scale_y_continuous("% Support Policy",limits=c(0.2,0.83),
                     breaks=seq(0,1,0.2),
                     labels=100*seq(0,1,0.2)) + 
  scale_x_discrete("Subgroup",breaks=x_labels$Subgroup,labels=x_labels$Subgroup_n) + 
  facet_wrap("Policy",ncol = 1) + 
  # geom_text(data=desc_tab,aes(x = Subgroup,y=0.20,label=n)) +
  theme_bw() + 
  theme(legend.position = "none",
        strip.text=element_text(size=18),
        axis.text = element_text(size=12))

plot(plot_desc_points_c)

########### Figure 2 #################
plot_treat_selfinterest <- ggplot(treatment_tab, aes(x=frame,group=cov)) +
  geom_errorbar(aes(ymin=ci.lo.95, ymax=ci.hi.95),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=0.35) +
  geom_errorbar(aes(ymin=ci.lo.90, ymax=ci.hi.90),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=1.5) +
  geom_point(aes(y=Estimate,shape=cov),position=position_dodge(width=0.2),
             data=treatment_tab,size=4) + 
  geom_hline(aes(yintercept=0),lty=2) + 
  # xlab(NULL) +
  ylab("Effect of financial self-interest\non policy support") +
  theme_bw() + 
  # scale_y_continuous(limits=c(-0.175, 0.005)) + 
  scale_x_discrete("Funding model") + 
  scale_shape_discrete("Covariate-\nadjusted",labels=c("No","Yes")) + 
  # coord_flip() + 
  theme(text=element_text(colour=black,
                          # family="CM Roman",
                          size=15),
        legend.position = "right")

plot(plot_treat_selfinterest)

########### Figure 3 #################

plot_treat_rep <- ggplot(treatment_tab, aes(x=frame,group=cov)) +
  geom_errorbar(aes(ymin=ci.lo.95, ymax=ci.hi.95),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=0.35) +
  geom_errorbar(aes(ymin=ci.lo.90, ymax=ci.hi.90),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=1.5) +
  geom_point(aes(y=Estimate,shape=cov),position=position_dodge(width=0.2),
             data=treatment_tab,size=4) + 
  geom_hline(aes(yintercept=0),lty=2) + 
  # xlab(NULL) +
  ylab("Effect of partisanship\non policy support") +
  theme_bw() + 
  # scale_y_continuous(limits=c(-0.175, 0.005)) + 
  scale_x_discrete("Funding model") + 
  scale_shape_discrete("Covariate-\nadjusted",labels=c("No","Yes")) + 
  # coord_flip() + 
  theme(text=element_text(colour=black,
                          # family="CM Roman",
                          size=15),
        legend.position = "right")
plot(plot_treat_rep)

########### Figure 4 #################
plot_treat_selfinterest_intx <- ggplot(treatment_tab, aes(x=Partisanship,group=cov)) +
  geom_errorbar(aes(ymin=ci.lo.95, ymax=ci.hi.95),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=0.35) +
  geom_errorbar(aes(ymin=ci.lo.90, ymax=ci.hi.90),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=1.5) +
  geom_point(aes(y=Estimate,shape=cov),position=position_dodge(width=0.2),
             data=treatment_tab,size=4) + 
  geom_hline(aes(yintercept=0),lty=2) + 
  facet_wrap("frame") + 
  # xlab(NULL) +
  ylab("Effect of financial self-interest\non policy support") +
  theme_bw() + 
  # scale_y_continuous(limits=c(-0.175, 0.005)) + 
  scale_x_discrete("Partisanship",limits=c("Republicans","Democrats")) + 
  scale_shape_discrete("Covariate-\nadjusted",labels=c("No","Yes")) + 
  # coord_flip() + 
  theme(text=element_text(colour=black,
                          # family="CM Roman",
                          size=15),
        legend.position = "right")
plot(plot_treat_selfinterest_intx)
########### Figure 5 #################
plot_treat_nimby_intx <- ggplot(treatment_tab, aes(x=Partisanship,group=cov)) +
  geom_errorbar(aes(ymin=ci.lo.95, ymax=ci.hi.95),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=0.35) +
  geom_errorbar(aes(ymin=ci.lo.90, ymax=ci.hi.90),position=position_dodge(width=0.2),
                data=treatment_tab,
                width=.0, size=1.5) +
  geom_point(aes(y=Estimate,shape=cov),position=position_dodge(width=0.2),
             data=treatment_tab,size=4) + 
  geom_hline(aes(yintercept=0),lty=2) + 
  # geom_vline(aes(xintercept=1.5),lty=1,lwd=3) + 
  facet_grid("Subgroups",scales = "free_x",space = "free_x") + 
  # xlab(NULL) +
  ylab("Effect of spatial self-interest\non policy support") +
  theme_bw() + 
  # scale_y_continuous(limits=c(-0.175, 0.005)) + 
  scale_x_discrete("") +
  scale_shape_discrete("Covariate-\nadjusted",labels=c("No","Yes")) + 
  # coord_flip() + 
  theme(text=element_text(colour=black,
                          # family="CM Roman",
                          size=15),
        legend.position = "right")

plot(plot_treat_nimby_intx)



